﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using DormMS.IService;
using DormMS.Model.SearchModels;

namespace WeChat.Controllers
{
    public class DropGroupController : BaseController
    {
        protected IDropGroupService dropgroupservice;
        protected IGroupHeadService groupheadservice;
        protected IOrderService orderservice;
        public DropGroupController(IMemberService s, IDropGroupService _dropgroupservice, IGroupHeadService _groupheadservice, IOrderService _orderservice) : base(s)
        {
            dropgroupservice = _dropgroupservice;
            groupheadservice = _groupheadservice;
            orderservice = _orderservice;
        }

        // GET: DropGroup
        public ActionResult Index()
        {
            return View();
        }
        /// <summary>
        /// 初始化数据
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpPost]
        public ActionResult GetGropGroupTop1()
        {
            return Json(new { Result = dropgroupservice.GetGropGroupTop1() });
        }

        /// <summary>
        /// 获取所有在时间内的活动
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ActionResult GetDropGroupListAll()
        {
            return Json(new { Results = dropgroupservice.GetDropGroupListAll() });
        }


        

        /// <summary>
        /// 获取降拼活动详情
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpPost]
        public ActionResult GetVDropGroupInfo(int id)
        {
            return Json(new { Result = dropgroupservice.GetVDropGroupInfo(id) });
        }

        /// <summary>
        /// 获取降拼活动详情
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult DropGroupInfo()
        {
            return View();
        }

      

        /// <summary>
        /// 团页面
        /// </summary>
        /// <returns></returns>
        public ActionResult GroupHeadList()
        {
            return View();
        }


        /// <summary>
        /// 获取该活动所有在时间内的团
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ActionResult GetGroupHeadListAll(int Skip, int Take, int dropgroupid)
        {
            int total = 0;
            var list = groupheadservice.GetGroupHeadList(Skip, Take, dropgroupid,ref total);
            return Json(new { Total = total, Results = list });
        }

        /// <summary>
        /// 团详情
        /// </summary>
        /// <returns></returns>
        public ActionResult GroupHeadInfo()
        {
            return View();
        }


        /// <summary>
        /// 获取团详情
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ActionResult GetGroupHeadInfo(int groupheadid)
        {
            int total = 0;
            var model = groupheadservice.GetGroupHeadInfo(groupheadid, ref total);
            return Json(new {  Result = model });
        }


        /// <summary>
        /// 初始化数据
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpPost]
        public ActionResult GetGropGroupByGroupID()
        {
            return Json(new { Result = dropgroupservice.GetGropGroupTop1() });
        }


        /// <summary>
        /// 我的降拼订单页
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult MyDropGroupOrderList()
        {
            return View();
        }

        /// <summary>
        /// 获取我的降拼订单
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ActionResult GetGroupOrderList(int Skip, int Take)
        {
            int total = 0;
            var member = _memberService.GetMemberInfo(CurrentLoginUser.Id);
            var list = orderservice.GetGroupOrderList(Skip, Take, member.Id, ref total);
            return Json(new { Total = total, Results = list });
        }


        /// <summary>
        /// 降拼活动首页
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult DropGroupIndex()
        {
            return View();
        }



    }
}